|
|
|
|
|
|
|
Figure 21.4
The Project Properties window. |
|
|
|
|
|
|
|
|
Checking for a Previous Instance |
|
|
|
|
|
|
|
|
You can use the PrevInstance property of the App object to determine whether the program should be loaded. In most cases, youll not want your user to have multiple copies of your program loaded. To accomplish this, use code like the following in the Sub Main() of your application: |
|
|
|
 |
|
|
|
|
Sub Main()
If App.PrevInstance Then
AppActivate "System Objects"
End
Else
frmMain.Show
End If
End Sub |
|
|
|
|
|
|
|
|
This code checks the App.PrevInstance property; if it returns a True value, the AppActivate command is called and passed in the title of the main form for the application. Windows will task switch over to that application; then this current instance of your program is ended. |
|
|
|
|
|
|
|
|
The Screen object provides you with information about the currently active screen elements. You can query this object to obtain the handle of the active form and the active control on that form. Youll also use this to set your mouse pointer to |
|
|
|
|
|